package com.example.intermediate_control;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

/**
  *
  * @description 圆角背景和椭圆背景点击切换
  * @param 
  * @return 
  * author snjgm
  * time 2022/10/31 下午3:07
  */
public class DrawableShapeActivity extends AppCompatActivity implements View.OnClickListener {

    private View shapeContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_drawable_shape);
        shapeContent = findViewById(R.id.tv_ShapeView);
        findViewById(R.id.btn_rect).setOnClickListener(this);
        findViewById(R.id.btn_oval).setOnClickListener(this);
        shapeContent.setBackgroundResource(R.drawable.shape_rect_gold);
    }

    @Override
    public void onClick(View v) {
         switch (v.getId()){
             case R.id.btn_rect:
                 shapeContent.setBackgroundResource(R.drawable.shape_rect_gold);
                 break;
             case R.id.btn_oval:
                 shapeContent.setBackgroundResource(R.drawable.shape_oval_rose);
                 break;
         }
    }
}